package com.qiaoyanqing.textdemoqyq7.Adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.qiaoyanqing.textdemoqyq7.Beans.Baike;
import com.qiaoyanqing.textdemoqyq7.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/11/15.
 */

public class HisAdapter extends BaseAdapter {
    private Context mContext;
    private List<Baike>mData=new ArrayList<>();


    public HisAdapter(Context context, List<Baike> data) {
        mContext = context;
        mData = data;
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int position, View convertview, ViewGroup parent) {
        ViewHolder holder=null;

        if (convertview == null) {
            holder=new ViewHolder();
            convertview= LayoutInflater.from(mContext).inflate(R.layout.hisdir,parent,false);
            holder.title= (TextView) convertview.findViewById(R.id.title);
            holder.source= (TextView) convertview.findViewById(R.id.source);
            holder.create_time= (TextView) convertview.findViewById(R.id.create_time);
            convertview.setTag(holder);
        }else {
            holder= (ViewHolder) convertview.getTag();
        }
        //赋值

            holder.title.setText(mData.get(position).getTitle());
            holder.source.setText(mData.get(position).getSource());
            holder.create_time.setText(mData.get(position).getCreate_time());

        return convertview;
    }

    static class ViewHolder{

        private  TextView title,source,create_time;

    }

}
